import React, { Component } from 'react'
import { Map } from "immutable";

export default class App extends Component {

    state = {
        info: Map({
            name: 'chuck',
            select: 'aa',
            filter: Map({
                text: '',
                open: true,
                down: false
            })
        })
    }
    componentDidMount() {
        console.log(this.state.info)
        console.log(this.state.info.get('filter')) // 打印出来还是普通对象
    }
    render() {
        return (
            <div>
                {this.state.info.get('name')}
                <div>
                    <button onClick={()=>{
                        this.setState({
                            info: this.state.info.set('name', 'jekins')
                        })
                    }}>edit Name</button>
                </div>
                <Child filter={this.state.info.get('filter')}></Child>
            </div>
        )
    }
}

class Child extends Component {
    render() {
      return (
        <div>03-map2</div>
      )
    }
    shouldComponentUpdate(nextProps, nextState){
        // console.log(nextProps.filter, this.props.filter)
        if (nextProps.filter == this.props.filter){
            return false
        }else {
            return true

        }
        // return true
    }
    componentDidUpdate(){
        // 为阻断这个影响
        console.log(this.props.filter, '更新')
    }
    componentDidMount(){
        console.log(this.props.filter)

    }
  }

